﻿<!DOCTYPE html>
<html>
<head>
    <title>企捷云</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
    <link rel="stylesheet" href="//at.alicdn.com/t/font_eedtp7mde99q9f6r.css">
    <link rel="stylesheet" type="text/css" href="/ViewV5/CSS/animate.css">
    <link rel="stylesheet" type="text/css" href="/ViewV5/CSS/bootstrap3.3.5/css/bootstrap.css">
    <link rel="stylesheet" type="text/css" href="/ViewV5/CSS/default.css">
    <link rel="stylesheet" type="text/css" href="/ViewV5/CSS/index.css">
    <style>
        .ms-controller, .ms-important, [ms-controller], [ms-important] {
            visibility: hidden;
        }

        .szhl_getPeoples {
            display: none;
        }
    </style>
</head>
<body ms-controller="KHCCLIST">
    <div style="margin-top:1rem;">
        <!-- 按条件选择 -->
        <div class="tab-filter-type">
            <!-- 搜索 -->
            <div class="oh">
                <div class="input-group ml15" style="width: 295px; float: left">
                    <input type="search" class="form-control" ms-duplex="search.searchcontent" placeholder="搜索客户名称">
                    <span class="input-group-addon" ms-click="GetLIST()">搜索</span>
                </div>
            </div>
        </div>
        <!-- 展开更多选项 -->
        <div class="add-tab ft14 tc mt20" style="display:none;">
            <span>更多筛选<i class="caret"></i></span>
        </div>
        <!-- 表格 -->
        <div class="default-tab ft14 pt20 table-responsive" style="margin-top:1rem;">
            <table class="table table-striped  table-hover">
                <thead>
                    <tr>
                        <th class="tc">
                         
                        </th>
                        <th ms-repeat-im="ShowColumns" ms-visible="im.IsSel">{{im.ColText}}</th>
                    </tr>
                </thead>
                <tbody>
                    <tr ms-repeat-el="ListData" ms-click="View(el.ID)">
                        <td class="tc">
                           
                        </td>
                        <td ms-repeat-im="ShowColumns" ms-css-min-width="im.width" ms-visible="im.IsSel">{{FnFormat(el[im.ColName],im)|html}}</td>
                    </tr>

                </tbody>
                <tfoot>
                    <tr ms-if="isnull"><td class="tc"></td><td>暂无数据</td></tr>
                </tfoot>
            </table>

        </div>
        <div class="ui-datatable-page ft14 pl20">

            <div id="pageDiv" ms-visible="tempindex.page.total>tempindex.pageNum[0].num" class="pull-right"></div>
            <div class="pull-right" ms-visible="ListData.size()!=0">
                <span>共{{tempindex.page.total}}条记录</span>
                <span ms-visible="model.page.total>model.pageNum[0].num">
                    选择每页条数
                    <select style="height: 25px; width: 50px;" ms-change="selNum(this.value)" ms-duplex="tempindex.page.pagecount">
                        <option ms-repeat-pg="pageNum" ms-attr-value="pg.num" ms-attr-selected="pg.num==tempindex.page.pagecount?'selected':''">{{pg.num}}</option>
                    </select>
                </span>
            </div>

        </div>
    </div>
    <script type="text/javascript" src="/ViewV5/JS/jquery-1.11.2.min.js"></script>
    <script src="/ViewV5/CSS/bootstrap3.3.5/js/bootstrap.js"></script>
    <script src="/ViewV5/JS/layer/layer.js"></script>
    <script src="/ViewV5/JS/layer/extend/layer.ext.js"></script>
    <script src="/ViewV5/JS/laypage/laypage.js"></script>
    <script src="/ViewV5/JS/toastr.js"></script>
    <script src="/ViewV5/JS/avalon1.47.js"></script>
    <script src="/ViewV5/JS/SZHLCommon.js?jsver=20160915"></script>
    <script>

        var tempindex = avalon.define({
            $id: "KHCCLIST",
            isnull: false,
            ShowColumns: [],  //显示的列名，数据在模板中填充
            ListData: [], //列表页数据
            search: { seartype: "0", searchcontent: getQueryString("name") },
            page: { pageindex: 1, pagecount: 10, total: 0 }, //分页参数
            pageNum: [{ "num": 10 }, { "num": 20 }, { "num": 30 }, { "num": 50 }, { "num": 100 }],
            selNum: function (item) {
                tempindex.page.pagecount = item;
                tempindex.GetLIST();
            },
            InitWigetData: function () {

                //显示的列名
                tempindex.ShowColumns.clear();
                tempindex.ShowColumns.pushArray([
                    { "ColName": "KHName", "ColText": "客户名称", "IsSel": true, "format": "text", "width": "120px" },

                    { "ColName": "FZUser", "ColText": "负责人", "IsSel": true, "format": "username", "width": "80px" },
                    { "ColName": "CRDate", "ColText": "创建时间", "IsSel": true, "format": "dateformat", "width": "100px" }
                ]);
                //类型数据

                tempindex.GetLIST();
            },

            GetLIST: function () {
                tempindex.page.pageindex = 1;
                tempindex.ListData.clear();
                $.getJSON('/API/VIEWAPI.ashx?Action=CRM_GETKHGLLIST', { p: 1, P1: 0, Content: tempindex.search.searchcontent, pagecount: tempindex.page.pagecount }, function (resultData) {
                        tempindex.ListData = resultData.Result;
                        if (tempindex.ListData.size() == 0) { tempindex.isnull = true; } else { tempindex.isnull = false; }
                        tempindex.page.total = resultData.Result1;
                        laypage({
                            cont: 'pageDiv', //容器。值支持id名、原生dom对象，jquery对象。
                            pages: Math.ceil(parseInt(resultData.Result1) * 1.0 / tempindex.page.pagecount), //通过后台拿到的总页数
                            curr: 1, //初始化当前页
                            skin: 'molv',
                            jump: function (e) { //触发分页后的回调
                                if (e.curr != tempindex.page.pageindex) {
                                    $.getJSON('/API/VIEWAPI.ashx?Action=CRM_GETKHGLLIST', { p: e.curr, P1: 0, Content: tempindex.search.searchcontent, pagecount: tempindex.page.pagecount }, function (resultData) {
                                            tempindex.ListData = resultData.Result;
                                    })
                                    tempindex.page.pageindex = e.curr;
                                }
                            }
                        });
                })
            },
            FnFormat: function (str, fmt) { //格式化
                str = str + "";
                if (str && fmt.format) {

                    switch (fmt.format) {
                        case "username": //用户id转成为用户名
                            {
                                str = ComFunJS.convertuser(str);
                            }
                            break;
                        case "text"://截取字符串
                            {
                                str = ComFunJS.convstr(str);
                            }
                            break;
                        case "dateformat": //日期格式，默认yyyy-mm-dd
                            {
                                str = ComFunJS.getnowdate("yyyy-mm-dd", str);
                            }
                            break;
                        case "timeformat": //日期格式，默认yyyy-mm-dd
                            {
                                str = ComFunJS.getnowdate("yyyy-mm-dd hh:mm", str);
                            }
                            break;
                        default: {

                        }
                    }


                }
                if (fmt.len) {
                    str = str.length > fmt.len ? str.substring(0, fmt.len) + '...' : str;
                }
                return str;

            }
        })
        avalon.ready(function () {
            tempindex.InitWigetData();
        })
        function getQueryString(name) {
            var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
            var r = window.location.search.substr(1).match(reg);
            if (r != null) return unescape(decodeURI(r[2])); return null;
        }
    </script>

</body>
</html>
